<{include file="public/header.html"}>
		<div class="xinsu-right">
			<div class="xinsu-right-content">
				<div class="xinsu-data-content">
					<div class="xinsu-title">
						<span class="layui-breadcrumb">
							<a><cite>当前位置</cite></a>
							<a><cite>用户委托</cite></a>
						</span>
					</div>
					<form class="layui-form xinsu-form" action="" method="get">
						<div class="layui-form-item">
						    <div class="layui-inline">
						      	<label class="layui-form-label xinsu-form-label">账号类型</label>
						      	<div class="layui-input-inline xinsu-input-inline">
							        <select name="demo_account">
										<option value="2">全部</option>
										<option value="0" <{if $demo_account == 0}>selected<{/if}>>正式</option>
										<option value="1" <{if $demo_account == 1}>selected<{/if}>>试玩</option>
									</select>
						        </div>
						    </div>
							 <div class="layui-inline">
						      	<label class="layui-form-label xinsu-form-label">委托状态</label>
						      	<div class="layui-input-inline xinsu-input-inline">
							        <select name="status">
										<option value="3">全部</option>
										<option value="0" <{if $status == 0}>selected<{/if}>>委托中</option>
										<option value="1" <{if $status == 1}>selected<{/if}>>已成交</option>
										<option value="2" <{if $status == 2}>selected<{/if}>>已撤单</option>
									</select>
						        </div>
						    </div>
							 <div class="layui-inline">
						      	<label class="layui-form-label xinsu-form-label">查询日期</label>
						      	<div class="layui-input-inline">
						        	<input type="text" name="start_time" placeholder="开始日期" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})" value="<{if $start_time != '0'}><{$start_time}><{/if}>">
						      	</div>
						      	<label class="layui-form-label xinsu-form-label2">至</label>
						      	<div class="layui-input-inline">
						        	<input type="text" name="end_time" placeholder="结束日期" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})" value="<{if $end_time != '0'}><{$end_time}><{/if}>">
						      	</div>
						    </div>
						    <div class="layui-inline">
						    	<label class="layui-form-label xinsu-form-label">搜索条件</label>
								<div class="layui-input-block xinsu-input-block2">
								    <input type="text" name="username" value="<{if $username != '0'}><{urldecode($username)}><{/if}>" class="layui-input" placeholder="帐号 / 真实姓名"/>
								</div>
						    </div>
						   <button class="layui-btn xinsu-btn">查询</button>
							<span>记录总数：共 <{$total}> 条</span>
						</div>
					</form>
					<div class="layui-form xinsu-form">
						<table class="layui-table">
							<thead>
								<tr>
									<th>ID</th>
									<th>帐号</th>
									<th>代码/名称</th>
									<th>委托时间</th>
									<th>成交时间</th>
									<th>股票类型</th>
									<th>委托类型</th>
									<th>委托价格</th>
									<th>最新价格</th>
									<th>委托数量</th>
									<th>委托状态</th>
									<th>操作</th>
								</tr> 
							</thead>
							<tbody>
								<{if empty($list) == false}>
								<{foreach $list as $val}>
								<tr id="xinsu-stock-<{$val.id}>" class="xinsu-stock-status">
									<td><{$val.id}></td>
									<td><a class="xinsu-fontcolor-blue xinsu-user" href="javascript:;" data="<{$val.uid}>"><{$val.username}></a></td>
									<td><a class="xinsu-fontcolor-blue xinsu-stock-figure" href="javascript:;" data="<{$val.stock}>"><{$val.stock}>/<{$val.stock_name}></a></td>
									<td><{date("Y-m-d H:i:s", $val["stock_trust_time"])}></td>
									<td><{if $val["stock_deal_time"] != 0}><{date("Y-m-d H:i:s", $val["stock_deal_time"])}><{/if}></td>
									<{if $val.bull_type == 1}>
									<td class="xinsu-fontcolor-red">融资↑</td>
									<{else}>
									<td class="xinsu-fontcolor-green">融券↓</td>
									<{/if}>
									<{if $val.trust_type == 1}>
									<td class="xinsu-fontcolor-red">委买</td>
									<{else}>
									<td class="xinsu-fontcolor-green">委卖</td>
									<{/if}>
									<td><{$val.price}></td>
									<td class="xinsu-fontcolor-red">--</td>
									<td><{$val.num}></td>
									<td><{if $val.status == 0}>委托中<{elseif $val.status == 1}>已成交<{else}>已撤单<{/if}></td>
									<td>
										<{if $val.status == 0}>
										<a class="xinsu-trust-cancel xinsu-fontcolor-blue" href="javascript:;" data="<{$val.id}>" >立即撤单</a>	
										<{else}>
										--
										<{/if}>
									</td>
								</tr>
								<{/foreach}>
								<tr>
									<td colspan="13">
										委托交易合计(总)：￥<{$count}>
									</td>
						        </tr>
								<{else}>
								<tr>
									<td colspan="12">暂无数据</td>
								</tr>
								<{/if}>
							</tbody>
						</table>
					</div>
					<div class="xinsu-page">
						<div class="xinsu-show">
							<{$page}>
						</div>
						<div class="xinsu-clear"></div>
					</div>
				</div>
			</div>
		</div>
		<script>
			//撤销委托单
			$('.xinsu-trust-cancel').click(function(){
				var id = $(this).attr("data");
				layer.confirm('您确定要撤销么？', {icon: 3}, function () {
					layer.closeAll();
					http_request_post("/stock/ajax_set_trust", {id:id, token:token}, function (result) {
						if (result.status == 1) {
							layer.msg(result.msg, {icon: 1, time: 800}, function () {
								location.reload();
							});
						} else {
							layer.msg(result.msg);
						}
					});
				});
			});
			<{if empty($list) == false}>
			$(function(){
				get_trust();
			})
			var stock = 0;
			//获取最新价格
			function get_trust() {
				if (stock >= 0 && system_holiday == 0) {
					var url = "/stock/ajax_get_trust";
					var data = "";
					$(".xinsu-stock-status").each(function(){
						var tmp = $(this).find("td").eq(0).html();
						if (tmp != undefined) {
							data += "," + tmp;
						}
					})
					http_request_post(url, {data:data}, function(result) {
						var res = result.data;
						$.each(res, function(key, val){
							var obj = $("#xinsu-stock-"+key).find("td");
							if (val.status == 1) {
								//已完成
								obj.eq(11).html("已完成");
								obj.eq(11).addClass("xinsu-fontcolor-red");
								obj.eq(12).html("--");
							} else if (val.status == 2) {
								//已撤销
								obj.eq(11).html("已撤销");
								obj.eq(11).removeClass("xinsu-fontcolor-green");
								obj.eq(12).html("--");
							} else {
								obj.eq(11).addClass("xinsu-fontcolor-green");
							}
							obj.eq(5).html(val["stock_deal_time"]);
							obj.eq(9).html(val["price"]);
						
						})
					});
				}
				stock = setTimeout("get_trust();", 1500);
			}
			<{/if}>
		</script>
<{include file="public/footer.html"}>
